package com.schoolai.schoolsystem.controller;

import com.schoolai.schoolsystem.jpa.repository.SysUserRepository;
import com.schoolai.util.base.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author bobby
 * @since 2025-10-14
 */
@RestController
@RequestMapping("/sysUser")
@Tag(name = "用户实体相关操作", description = "用户实体相关操作")
public class SysUserController {


    @Autowired
    SysUserRepository sysUserRepository;

    @Operation(summary = "根据用户名查询用户")
    @PostMapping("/search")
    @ApiResponses({
            @ApiResponse(responseCode = "20000", description = "操作成功"),
            @ApiResponse(responseCode = "999", description = "错误")
    })
    public Result search(
            @Parameter(description = "用户名", required = true, example = "admin")
            @RequestParam("userName") String userName
    ){
         return Result.ok(sysUserRepository.findByUsername(userName));
    }

}
